import { atom, selector } from 'recoil'
import { isNullData } from '@/utils'
// 顶部导航栏用户信息

// accountType 0  10  20  30  40  管理员的类型
type User = {
  id: number
  username: string
  platformId: number
  password: null | string
  telphone: null | string
  phone: string
  email: string
  accountType: number
  provinceId: null | number
  cityId: null | number
  areaId: null | number
  inpatientWardId: null | number
  hospitalCode: number
  lastLoginDate: string
  createDate: string
  updateDate: string
  createUser: string
  updateUser: string
  status: boolean
  isDeleted: boolean
  perms: string[]
  hospitalName: string
  areaName: string // 地区
  cityName: string // 城市
  provinceName: string // 省
  loginTimes: number // 登录次数
}

// import { useRecoilValue } from 'recoil'
// import { userInfo } from '@/store/userInfo'
// const user = useRecoilValue(userInfo)

export const userInfo = atom({
  key: 'userInfo',
  default: <User>{},
})

// export const proviencsDataSelector = selector({
//   key: 'proviencsDataSelector',
//   get: async (): Promise<any> => {
//     const res = await getSelectTree()
//     // console.log('看一下三级联动数据是什么样子', res.data)
//     if (isNullData(res)) {
//       return convertDataToCascaderFormat(res.data)
//     }
//     return []
//   },
// })
